package com.compass.doctor.dialog

import android.view.Gravity
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.fragment.app.FragmentActivity
import com.compass.doctor.callback.OnCustomButtonClick
import com.compass.doctor.databinding.DialogFinishInquiryBinding
import com.compass.framework.base.BaseDialog
import com.compass.framework.base.BaseDialogFragment
import com.compass.framework.ext.onClick
import com.compass.framework.toast.TipsToast

/**
 * Description： 结束问诊弹窗
 * Date:2023/12/14 16:59
 */
class FinishInquiryDialog {
    class Builder(activity: FragmentActivity, comeType: Int, onBottomClick: OnCustomButtonClick) :
        BaseDialogFragment.Builder<Builder>(activity) {


        private var comeType: Int//2 结束问诊 1 退诊
        private var onBottomClick: OnCustomButtonClick
        private val mBinding: DialogFinishInquiryBinding =
            DialogFinishInquiryBinding.inflate(LayoutInflater.from(activity))
        var title: String? = null
        var content: String? = null
        var tips: String? = null

        init {
            this.comeType = comeType
            this.onBottomClick = onBottomClick
            initView()
        }

        private fun initView() {
            setContentView(mBinding.root)
            setWidth(ViewGroup.LayoutParams.MATCH_PARENT)
            setHeight(ViewGroup.LayoutParams.WRAP_CONTENT)
            setAnimStyle(BaseDialog.AnimStyle.BOTTOM)
            gravity = Gravity.BOTTOM
            if (comeType == 2) {
                title="诊后建议"
                content="请输入诊后建议（200字内）"
                tips="请输入诊后建议"
            } else {
                title="退诊原因"
                content="请输入退诊原因（200字内）"
                tips="请输入退诊原因"
            }
            mBinding.refusalInfo.text =title
            mBinding.edtMsgSuggestion.hint = content

            mBinding.tvRefusal.onClick {
                var suggest = mBinding.edtMsgSuggestion.text.toString().trim()
                if (suggest.isEmpty()) {
                    TipsToast.showTips(tips)
                    return@onClick
                }

                dismiss()
                onBottomClick.onButtonCallBack(1, suggest)
            }
            mBinding.tvCancel.onClick {
                dismiss()
            }
        }


    }
}